import { Column, CreateDateColumn, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { User } from './users.entity';

@Entity()
export class Food {
    constructor(props?: Partial<Food>) {
        Object.assign(this, props);
    }

    @PrimaryGeneratedColumn('uuid')
    public id!: string;

    @ManyToOne(() => User, (user) => user.telegramId)
    public user!: User;
    @Index()
    @Column({ nullable: true })
    public userTelegramId!: string;

    @ApiProperty({ example: 'apple', description: 'name  food' })
    @Column({
        nullable: true,
    })
    public nameFood!: string;

    @ApiProperty({ example: '12.90', description: 'count calories food' })
    @Column({
        nullable: true,
        type: 'numeric',
    })
    public calories!: number;

    @ApiProperty({ example: '12.90', description: 'count protein food' })
    @Column({
        nullable: true,
        type: 'numeric',
    })
    public protein!: number;

    @ApiProperty({ example: '12.90', description: 'count totalFat food' })
    @Column({
        nullable: true,
        type: 'numeric',
    })
    public totalFat!: number;

    @ApiProperty({ example: '12.90', description: 'count carbohydrate food' })
    @Column({
        nullable: true,
        type: 'numeric',
    })
    public carbohydrate!: number;

    @ApiProperty({ example: 'https://www.google.com', description: 'url to image food' })
    @Column({
        nullable: true,
    })
    public urlImage!: string;

    @ApiProperty({ example: '21.23.1990', description: 'date registration' })
    @CreateDateColumn({ nullable: true, name: 'created_at', type: 'timestamptz' })
    createdAt!: Date;
}
